package com.softdev.controller;

import com.softdev.common.R;
import com.softdev.pojo.Skill;
import com.softdev.service.SkillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api("技能操作")
@Slf4j
@RestController
@RequestMapping("/skill")
public class SkillController {

    @Resource
    private SkillService skillService;

    @ApiOperation("查看技能")
    @GetMapping
    public R<List<Skill>> get() {

        List<Skill> skills = skillService.get();

        return R.success(skills);
    }

    @ApiOperation("新建技能")
    @PostMapping
    public R<String> add(@RequestBody Skill skill) {

        if (skillService.add(skill)) {
            return R.success("技能创建成功！");
        }

        return R.error("技能创建失败...");
    }

}
